<?php
/**
 * Room Model for Room Booking Component
 * 
 * @version 1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license		GNU/GPL
 */
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.model' );
 
class RoomBookingModelRoom extends JModel
{	
    /**
	 * Method to get Organization name
	 * @return	string
	 */
    function getRoomName($id_room)
    {
		$db =& JFactory::getDBO();
 
  		$query = 'SELECT  name FROM #__roombooking_rooms WHERE id='.$id_room;
		$db->setQuery( $query );
   		$room = $db->loadObject();

   		return $room->name;
    	
    }
    
    /**
	 * Method to get cost
	 * @return  int
	 */
    function getRoomCost($id_room)
    {
		$db =& JFactory::getDBO();
 
  		$query = 'SELECT cost FROM #__roombooking_rooms as r,#__roombooking_rooms_types as t WHERE r.room_type_id = t.id AND r.id='.$id_room;
                
		$db->setQuery( $query );
   		$room = $db->loadObject();

   		return $room->cost;
    	
    }
    
    /**
	 * Method to get id of building room 
	 * @return int
	 */    
	function getIdBuildOfRoom($id_room)
    {
		$db =& JFactory::getDBO();
 
  		$query = 'SELECT  id_building FROM #__roombooking_rooms WHERE id='.$id_room;
		$db->setQuery( $query );
   		$room = $db->loadObject();
   		
   		return $room->id_building;
    	
    }
}
